package com.example.springbootsenior.ExceptionHandler.controller;

import com.example.springbootsenior.AOP.manager.user.pojo.User;
import com.example.springbootsenior.ExceptionHandler.exception.LoginException;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <pre>
 * 功能描述:
 * </pre>
 *
 * @author: 李明杰
 * @date: 2022/3/3 14:13
 */
@RestController
public class SysIndexController {
    /**
     * 首页方法
     */
    @GetMapping("/loginException")
    public String index(ModelMap mmap) {
        /**
         * 模拟用户未登录，抛出业务逻辑异常
         */
        User user = null;//ShiroUtils.getSysUser();
        if (user == null) {
            throw new LoginException("用户未登录，无法访问请求。");
        }
        mmap.put("user", user);
        return "index";
    }
}